package com.modular.iot.action;

import cn.hutool.core.util.StrUtil;
import com.ToolOpt;
import ntd.action.ActionAbs;
import ntd.action.bo.ActionInfo;
import ntd.action.bo.ActionOutBo;

public class ActionIotDeviceConfig extends ActionAbs {

    @Override
    public ActionInfo info() {
        return new ActionInfo("设备配置", "iot-device-config", new ActionIotDeviceConfig());
    }

    @Override
    public ActionOutBo handle() {
        // 设置配置类型 - 适配之前接口，增加默认值 video-move
        String configType = StrUtil.blankToDefault(actionInBo.getParamStr("configType"), "video-move");
        ToolOpt.OPT_T_D_CONFIG.updateByBlock(actionInBo.getDataCode(), configType, actionInBo.getDataStr());
        // 返回最新配置信息
        return new ActionOutBo(ToolOpt.OPT_T_D_CONFIG.getConfig(actionInBo.getDataCode()));
    }
}
